/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SComplaintConverter.java
 * Created：		2016年8月21日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.repair.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.common.ASubjectWithDirectionConverter;
import com.thor.palmmall.rest.repair.ARepairConfig;
import com.thor.palmmall.spi.maintain.SDefaultConfig;

/**
 * @author wolv
 *
 */
public class ARepairConfigConverter implements Converter<SDefaultConfig, ARepairConfig> {

	public static ARepairConfigConverter getInstance() {
		if (instance == null)
			instance = new ARepairConfigConverter();
		return instance;
	}

	private static ARepairConfigConverter instance;

	private ARepairConfigConverter() {
	}

	@Override
	public ARepairConfig convert(SDefaultConfig source) {
		if (source == null)
			return null;

		ARepairConfig target = new ARepairConfig();
		target.setArtificialSubject(ASubjectWithDirectionConverter.getInstance().convert(source.getArtificialSubject()));
		target.setMaterialSubject(ASubjectWithDirectionConverter.getInstance().convert(source.getMaterialSubject()));
		target.setWarehouse(UCN.newInstance(source.getWarehouse()));
		target.setPartsSubject(ASubjectWithDirectionConverter.getInstance().convert(source.getPartsSubject()));
		target.setRoles(source.getRoles());
		return target;
	}
}
